<template>
	<view>
		<header-top :messageInfo="{typeFlag:true,message:'关于我们',liner:false}"></header-top>
		<view class="flexcolumn abouttop">
			<view class="logoimg">
				<image src="../../static/image/system/zuanshi.png" mode=""></image>
			</view>
			<view class="mainpadding">
				<view class="titletext margin_top">当前版本{{version}}</view>
			</view>
		</view>
		<!-- 内容 -->
		<view class="mainpadding margin_top">
			<view class="flexbetween needbotborder" @click="userinfo(1)">
				<view class="strongtext">使用协议</view>
				<view class="righticon2"></view>
			</view>
			<view class="flexbetween needbotborder"  @click="userinfo(2)">
				<view class="strongtext">隐私政策</view>
				<view class="righticon2"></view>
			</view>
			<view class="flexbetween needbotborder" @click="phone(userlist.company_info.company_phone)">
				<view class="strongtext">客服热线</view>
				<view class="maincolor_text">{{userlist.company_info.company_phone}}</view>
			</view>
			<view class="flexbetween needbotborder" @click="clearCache">
				<view class="strongtext">清除数据</view>
				<view class="flexright">
					<view class="maincolor_text margin_right">{{fileSizeString}}</view>
					<view class="righticon2"></view>
				</view>
			</view>
			<!-- <view class="flexbetween margin_top">
				<view class="strongtext">问题反馈</view>
				<view class="righticon2"></view>
			</view> -->
		</view>

	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				fileSizeString: "",
				version:"",
				userlist:{
					user_info:{
						avatar:"",
						name:"",
						phone:""
					},
					company_info:{
						company_name:"",
						company_address:"",
						company_phone:""
					}
				}
			}
		},
		created() {
			this.formatSize()
			this.userxinxi()
		},
		onLoad() {
			this.getVersion()
		},
		methods: {
			userxinxi() {
				// if(!this.isLogin){
				// 	return
				// }
				httpRequest.request('appapi/manage/user/info', 'POST', {
					// 传参
				}, false, false, true).then(res => {
					if(res.code == 1){
						this.userlist = res.data
					}
				})
			},
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			},
			// 获取版本号
			getVersion() {
				// 获取本地应用资源版本号
				plus.runtime.getProperty(plus.runtime.appid, (info) => {
					console.log(JSON.stringify(info),999);
					this.version = info.version;
				})
			},
			//缓存计算
			formatSize() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						let size = res.currentSize;
						if (size < 1024) {
							that.fileSizeString = size + ' B';
						} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
							that.fileSizeString = Math.floor(size / 1024 * 100) / 100 + ' KB';
						} else if (size / 1024 / 1024 >= 1) {
							that.fileSizeString = Math.floor(size / 1024 / 1024 * 100) / 100 + ' M';
						}
					}
				})
			},
			// 清楚缓存
			clearCache() {
				let that = this;
				uni.clearStorageSync();
				//重新获取并显示清除后的缓存大小
				that.formatSize();
				// uni.showToast({
				// 	title:'清除成功'
				// })
				httpRequest.toast("清除成功")
				setTimeout(() => {
					uni.reLaunch({
						url: "/pages//login/accountlogin"
					})
				}, 1000)
			},
			userinfo(value) {
				uni.navigateTo({
					url: "/pages/systempage/systempage?type=" +value
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.abouttop {
		margin-top: 150rpx;
	}

	.logoimg {
		width: 162rpx;
		height: 162rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.needbotborder {
		padding: 30rpx 0;
		border-bottom: 1rpx solid rgba(153, 153, 153, 0.05);
	}

	.maincolor_text {
		color: #0bbdcb;
		font-size: 28rpx;
	}
</style>
